package com.kuaiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kuaiyin.entity.User;
import com.kuaiyin.vo.UserVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户基础信息表（使用逻辑外键） Mapper 接口
 * </p>
 *
 * @author ng
 * @since 2025-04-21
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("select name departmentName from departments where id = #{departmentId}")
    String getDepartmentById(Integer departmentId);

    @Select( "select count(*) from user where username = #{username}")
    Integer getUserByUsername(String username);

    List<UserVO> selectAllWithDept();

    @Select("select count(*) from user where phone = #{phone}")
    Integer getUserByPhone(String phone);

    @Select("select count(*) from user where email = #{email}")
    Integer getUserByEmail(String email);
}
